Calendar All Tests
Current file: /home/estudydev/workspace/eStudy_svn/web/calendar/classes/class.functions.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
62.50 %62.50%
62.50% 5 / 8
39.68 %39.68%
39.68% 25 / 63
 
Functions
100.00 %100.00%
100.00% 1 / 1
62.50 %62.50%
62.50% 5 / 8
39.68 %39.68%
39.68% 25 / 63
 public static function message_redirect($msg, $url)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 public static function checktime($hour, $minute)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public static function getDateAsString($date)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public static function getTimeAsString($date)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public static function compress_page($output)
100.00 %100.00%
100.00% 1 / 1
28.57 %28.57%
28.57% 4 / 14
 public static function r_stripslashes(&$array)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 11 / 11
 public static function forum_query($query)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 6 / 6
 public function getColor($name, $id)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 22


       1                 : <?php                                                                                                                                                                
       2                 : /*--------------------------------------------------------------------------+                                                                                        
       3                 : This file is part of eStudy.                                                                                                                                         
       4                 : forum/classes/class.functions.inc.php                                                                                                                                
       5                 : - Modulgruppe:  Calendar                                                                                                                                             
       6                 : - Beschreibung: Klasse zur Verwaltung von Hilfsfunktionen für den Calendar.                                                                                         
       7                 : - Version:      0.1, 12/04/2006                                                                                                                                      
       8                 : - Autor(en):    Nadja Krümmel <nadja@kruemmel.info>                                                                                                                 
       9                 : +---------------------------------------------------------------------------+                                                                                        
      10                 : This program is free software; you can redistribute it and/or                                                                                                        
      11                 : modify it under the terms of the GNU General Public License                                                                                                          
      12                 : as published by the Free Software Foundation; either version 2                                                                                                       
      13                 : of the License, or any later version.                                                                                                                                
      14                 : +---------------------------------------------------------------------------+                                                                                        
      15                 : This program is distributed in the hope that it will be useful,                                                                                                      
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                       
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                        
      18                 : GNU General Public License for more details.                                                                                                                         
      19                 : You should have received a copy of the GNU General Public License                                                                                                    
      20                 : along with this program; if not, write to the Free Software                                                                                                          
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                          
      22                 : +--------------------------------------------------------------------------*/                                                                                        
      23                 : require_once (PATH_TO_ROOT."calendar/header.inc.php");                                                                                                               
      24                 : /**                                                                                                                                                                  
      25                 :  * Klasse zur Verwaltung von Hilfsfunktionen für den Calendar.                                                                                                      
      26                 :  * @package eStudy.Calendar                                                                                                                                          
      27                 :  * @author Nadja Krümmel <nadja@kruemmel.info>                                                                                                                      
      28                 :  * @version 0.1, 12/04/2006                                                                                                                                          
      29                 :  */                                                                                                                                                                  
      30                 : class Functions {                                                                                                                                                    
      31                 :     public static function message_redirect($msg, $url) {                                                                                                            
      32               7 :         $TRedirect = new Template(PATH_TO_ROOT."calendar/templates/redirect.html");                                                                                  
      33               7 :         eval($TRedirect->GetTemplate());                                                                                                                             
      34               7 :     }                                                                                                                                                                
      35                 :     public static function checktime($hour, $minute) {                                                                                                               
      36               0 :         if ($hour < 0 || $hour > 23) {                                                                                                                               
      37               0 :             return false;                                                                                                                                            
      38                 :         }                                                                                                                                                            
      39               0 :         if ($minute < 0 || $minute > 59) {                                                                                                                           
      40               0 :             return false;                                                                                                                                            
      41                 :         }                                                                                                                                                            
      42               0 :         return true;                                                                                                                                                 
      43                 :     }                                                                                                                                                                
      44                 :     /**                                                                                                                                                              
      45                 :      * Formatiert ein Datum in einen String                                                                                                                          
      46                 :      * @access private                                                                                                                                               
      47                 :      * @param $date zur formatierendes Datum                                                                                                                         
      48                 :      * @author Nadja Kruemmel <nadja@kruemmel.info>                                                                                                                  
      49                 :      * @return liefert eine formatiertes Datum als String zurueck.                                                                                                   
      50                 :      */                                                                                                                                                              
      51                 :     public static function getDateAsString($date) {                                                                                                                  
      52               1 :         return substr($date, 8, 2) .".".substr($date, 5, 2) .".".substr($date, 0, 4);                                                                                
      53                 :     }                                                                                                                                                                
      54                 :     public static function getTimeAsString($date) {                                                                                                                  
      55               0 :         return substr($date, 11, 2) .":".substr($date, 14, 2);                                                                                                       
      56                 :     }                                                                                                                                                                
      57                 :     public static function compress_page($output) {                                                                                                                  
      58              13 :         global $_SERVER, $config;                                                                                                                                    
      59              13 :         if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzcompress') && $config['compression']) {
      60               0 :             $output.= '<!-- gzcompress()ed -->';                                                                                                                     
      61                 :             // http://www.p hp.net/manual/en/function.gzcompress.p hp -- comments                                                                                    
      62               0 :             header('Content-Encoding: gzip');                                                                                                                        
      63               0 :             $size = strlen($output);                                                                                                                                 
      64               0 :             $crc = crc32($output);                                                                                                                                   
      65               0 :             $output = gzcompress($output, 1);                                                                                                                        
      66               0 :             print "\x1f\x8b\x08\x00\x00\x00\x00\x00";                                                                                                                
      67               0 :             print substr($output, 0, strlen($output) -4);                                                                                                            
      68               0 :             print pack('V', $crc);                                                                                                                                   
      69               0 :             print pack('V', $size);                                                                                                                                  
      70               0 :         } else {                                                                                                                                                     
      71              13 :             print $output;                                                                                                                                           
      72                 :         }                                                                                                                                                            
      73              13 :     }                                                                                                                                                                
      74                 :     public static function r_stripslashes(&$array) {                                                                                                                 
      75               1 :         while (list($k, $v) = each($array)) {                                                                                                                        
      76               1 :             if ($k != 'argc' && $k != 'argv' && (strtoupper($k) != $k || ''.intval($k) == "$k")) {                                                                   
      77               1 :                 if (is_string($v)) {                                                                                                                                 
      78               1 :                     $array[$k] = stripslashes($v);                                                                                                                   
      79               1 :                 }                                                                                                                                                    
      80               1 :                 if (is_array($v)) {                                                                                                                                  
      81               1 :                     $array[$k] = Functions::r_stripslashes($v);                                                                                                      
      82               1 :                 }                                                                                                                                                    
      83               1 :             }                                                                                                                                                        
      84               1 :         }                                                                                                                                                            
      85               1 :         return $array;                                                                                                                                               
      86                 :     }                                                                                                                                                                
      87                 :     public static function forum_query($query) {                                                                                                                     
      88               5 :         $result = mysql_query($query);                                                                                                                               
      89               5 :         if (mysql_errno()) {                                                                                                                                         
      90               3 :             echo "Modul Calendar (class.functions.inc.php): Fataler Fehler bei SQL Abfrage aufgetreten!";                                                            
      91               3 :         } else {                                                                                                                                                     
      92               5 :             return $result;                                                                                                                                          
      93                 :         }                                                                                                                                                            
      94               3 :     }                                                                                                                                                                
      95                 :     public function getColor($name, $id) {                                                                                                                           
      96                 :         //Name in Farbe umwandeln                                                                                                                                    
      97               0 :         $hash = md5($name.$id);                                                                                                                                      
      98               0 :         $rgb = substr($hash, 0, 6);                                                                                                                                  
      99               0 :         while (true) {                                                                                                                                               
     100                 :             //überprüfen, wieviele Komponenten >200 sind                                                                                                           
     101               0 :             $c = 0;                                                                                                                                                  
     102               0 :             for ($i = 0 ; $i < 3 ; ++$i) {                                                                                                                           
     103               0 :                 $a = $rgb[$i*2].$rgb[$i*2+1];                                                                                                                        
     104               0 :                 if (hexdec($a) >= 200) {                                                                                                                             
     105               0 :                     ++$c;                                                                                                                                            
     106               0 :                 }                                                                                                                                                    
     107               0 :             }                                                                                                                                                        
     108                 :             //wenn 2 Komponenten >200 dann OK                                                                                                                        
     109               0 :             if ($c >= 2) {                                                                                                                                           
     110               0 :                 break;                                                                                                                                               
     111                 :             }                                                                                                                                                        
     112                 :             //sonst Farbe aufhellen                                                                                                                                  
     113               0 :             $newcolor = "";                                                                                                                                          
     114               0 :             for ($i = 0 ; $i < 3 ; ++$i) {                                                                                                                           
     115               0 :                 $a = $rgb[$i*2].$rgb[$i*2+1];                                                                                                                        
     116               0 :                 $b = hexdec($a) +10;                                                                                                                                 
     117               0 :                 $c = dechex($b > 255 ? 255 : $b);                                                                                                                    
     118               0 :                 $newcolor.= (strlen($c) == 1 ? "0".$c : $c);                                                                                                         
     119               0 :             }                                                                                                                                                        
     120               0 :             $rgb = $newcolor;                                                                                                                                        
     121               0 :         }                                                                                                                                                            
     122               0 :         return $rgb;                                                                                                                                                 
     123                 :     }                                                                                                                                                                
     124                 : }                                                                                                                                                                    

Generated by PHPUnit 3.2.21 and Xdebug 2.0.3 at Thu Nov 26 17:01:15 CET 2009.